{include file="public/header" /}
<body>
<section class="main-content-wrapper">
	<section id="main-content">
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-heading">
						<h3 class="panel-title">url推广</h3>
					</div>
					<div class="panel-body">
						<div class="form-horizontal form-border">
							<div class="form-group">
								<label class="col-sm-2 control-label"></label>
								<div class="col-sm-8">
									<div class="col-lg-6">
										<div style="width: 100%;height: 300px;overflow-y: auto;" id="all_url">{volist name="url" id="vo"}{$vo.url}=lh<br />{/volist}
										</div>
									</div>
									<div class="col-lg-6">
										<div style="width: 100%;height: 300px;overflow-y: auto;" id="short_url"></div>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label"></label>
								<div class="col-sm-8">
									<button type="button" class="btn btn-block btn-success" data-type="1">一、生成短链接</button>
									<button type="button" class="btn btn-block btn-success" data-type="2">二、</button>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
</section>
<script>
	$(document).on('click','button',function(){
		var type = $(this).attr('data-type');
		if(type==1){
			get_short_url();
		}else{
			tuiguang_url();
		}
	});
	function get_short_url(){
		var all_url = $("#all_url").text();
		$.ajax({
			type: "POST",
			url: "/admin/seo/get_short_url",//路径
			data: {all_url:all_url},
			dataType: "json",
			success: function (data) {
				if(data.status==0){
					var data = data.data;
					html = [];
					for (var i=0;i<data.length;i++)
					{
						html += data[i]+'<br />';
					}
					$('#short_url').html(html);
				}else{

				}
			}
		});
	}

	function tuiguang_url(){
		var con = $('#short_url').val();
		if(con==''){
			alert('链接不能为空');return;
		}
		$.ajax({
			type: "POST",
			url: "/admin/seo/tuiguang_url",//路径
			data: {short_url:con},
			dataType: "json",
			success: function (data) {
				if(data.status==0){

				}else{

				}
			}
		});
	}

</script>
</body>
</html>
